//
//  LatestDetailViewController.m
//  项目一
//
//  Created by 王鑫 on 15/11/15.
//  Copyright (c) 2015年 王鑫. All rights reserved.
//

#import "LatestDetailViewController.h"
#import "LatestModel.h"
#import "AFNetworking.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height

@interface LatestDetailViewController ()

@property(nonatomic, retain) NSString *stringURL;

@end

@implementation LatestDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self createData];
}
#pragma mark - Method createData
- (void)createData {
    LatestModel *temp = self.model;
    NSString *string = @"http://cont.app.autohome.com.cn/autov5.0.0/content/news/newsinfo-pm1-i";
    NSString *string1 = @".json";
    NSString *strUrl = [NSString stringWithFormat:@"%@%@%@", string, temp.idNew, string1];
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    [manager GET:strUrl parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSDictionary *dic = responseObject;
        self.stringURL = dic[@"result"][@"url"];
        
        UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, -80, WIDTH, HEIGHT + 80)];
        [self.view addSubview:webView];
        NSURL *url = [NSURL URLWithString:self.stringURL];
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        [webView loadRequest:request];
        [webView release];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
